package com.garz.utill;

import com.eidlink.vals.sdk.constants.PublicParam;
import com.eidlink.vals.sdk.constants.UserInfoParam;
import com.eidlink.vals.sdk.pojo.request.ImageCheckParam;
import com.eidlink.vals.sdk.pojo.request.SimpleCheckParam;
import com.eidlink.vals.sdk.pojo.result.CommonResult;
import com.eidlink.vals.sdk.service.EidlinkService;

import net.sf.json.JSONObject;

public class ConstantUtil {
	
	/*
	 * 简项查询   
	 */
	public static void SimpleCheck(String name,String idCard) {
		// 个人信息（姓名、身份证号码、不为空） 
				UserInfoParam userInfo = new UserInfoParam(name,idCard);
				// biz_sequence_id 业务流水号(可空) 
				String biz_sequence_id = "";
				// security_factor 报文参数安全因子(可空) 
				JSONObject security_factor = new JSONObject();
				String encrypt_factor = "9ba8b225a82814d5"; 
				security_factor.element("encrypt_factor", encrypt_factor);
				String sign_factor = "a0be32d15a3b0623";
				security_factor.element("sign_factor", sign_factor); 
				// 消息扩展(可空) 
				Object extension = null; 
				// 透传参数(可空) 
				String attach = "";
				PublicParam publicParam = new PublicParam(biz_sequence_id, security_factor.toString(), extension,attach);
				SimpleCheckParam simpleCheckParam = new SimpleCheckParam(publicParam,userInfo);
				CommonResult result = EidlinkService.SimpleCheck(simpleCheckParam);
				// 00:返回正确结果 
				if ("00".equals(result.getResult())) { 
					System.out.println("ok");
					System.out.println("简项查询返回结果：" + JSONObject.fromObject(result).toString());
				} else{ 
					System.out.println("简项查询返回结果：" + result.getResult() + " === " + result.getResult_detail()); 
				} 		
		}
	
	
	
	
	/**
	 * OCR双面查询
	 */
	public static void idCardOCR(String imgUrl){
	
		
				// 图片信息
					PublicParam publicParam = new PublicParam(); 
					ImageCheckParam imageCheckParam = new ImageCheckParam(publicParam, ImgUtil.getImageStr(imgUrl));
					CommonResult result = EidlinkService.ocrMoreCheck(imageCheckParam);
					// 00:返回正确结果 
					if ("00".equals(result.getResult())){
						System.out.println("===== OCR双面结果正常：" + JSONObject.fromObject(result).toString());
					} else {
						System.out.println("===== OCR双面结果异常：" + JSONObject.fromObject(result).toString());
					}
	}
	
	
	
	
	public static void main(String[] args) {
		ConstantUtil.idCardOCR("C:\\Users\\Administrator\\Desktop\\a.jpg");
		ConstantUtil.SimpleCheck("wangpeng","410323199103144014");
	}
	
	
	
	
	
 
}
